package thisdemo;

class Time{
	int year;
	
	public Time yearIncre() {
		year++;
		//当返回值,返回调用此方法的对象本身
		return this;
	}
}

public class ThisDemo2 {
	public static void main(String[] args) {
		Time t = new Time();
		t.year = 2022;
		// 当t调用完yearIncre()就把自己返回来，所以可以继续调用
		t.yearIncre().yearIncre().yearIncre().yearIncre().yearIncre();
		System.out.println(t.year);
		
		StringBuffer sb = new StringBuffer();
		sb.append("abc").append(true).append(1.1).append('a');
		System.out.println(sb);
	}
}
